/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package caa.struts.user.form;

import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import th.com.entity.DepartmentEntity;
import th.com.entity.FacultyEntity;
import th.com.entity.UserEntity;
import th.com.entity.UserTypeEntity;

/**
 *
 * @author Ketsaraporn
 */
public class ManageUserForm extends ActionForm {

    private String UserId = "";
    private String UserName = "";
    private String UserPassword = "";
    private String UserTitle = "";
    private String UserFirstName = "";
    private String UserLastName = "";
    private String UserPosition = "";
    private String FacultyName = "";
    private String DepartmentName = "";
    private String UserTypeDesc = "";
    private int UsertypeId;
    private String kwKeyWord = "";
    
    
//    private String error;
    private UserEntity userEntity = new UserEntity();  
    private ArrayList<UserEntity> UserList = new ArrayList<UserEntity>();
    private ArrayList<FacultyEntity> facultyList = new ArrayList<FacultyEntity>();
    private ArrayList<DepartmentEntity> DepartmentList = new ArrayList<DepartmentEntity>();
    private UserTypeEntity userTypeEntity = new UserTypeEntity();
    private ArrayList<UserTypeEntity> UserTypeList = new ArrayList<UserTypeEntity>();
    private String mode = "";

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }
    
    public boolean getModeEdit() {
        boolean rs = false;
        if(this.mode.equalsIgnoreCase("edit")) {
            rs = true;
        }
        return rs;
    }

    //    เพื่อแสดง ชื่อสถานะ
    /**
     * @return the UserId
     */
    public String getUserId() {
        return UserId;
    }

    /**
     * @param UserId the UserId to set
     */
    public void setUserId(String UserId) {
        this.UserId = UserId;
    }

    /**
     * @return the UserName
     */
    public String getUserName() {
        return UserName;
    }

    /**
     * @param UserName the UserName to set
     */
    public void setUserName(String UserName) {
        this.UserName = UserName;
    }

    /**
     * @return the UserPassword
     */
    public String getUserPassword() {
        return UserPassword;
    }

    /**
     * @param UserPassword the UserPassword to set
     */
    public void setUserPassword(String UserPassword) {
        this.UserPassword = UserPassword;
    }

    /**
     * @return the UserTitle
     */
    public String getUserTitle() {
        return UserTitle;
    }

    /**
     * @param UserTitle the UserTitle to set
     */
    public void setUserTitle(String UserTitle) {
        this.UserTitle = UserTitle;
    }

    /**
     * @return the UserFirstName
     */
    public String getUserFirstName() {
        return UserFirstName;
    }

    /**
     * @param UserFirstName the UserFirstName to set
     */
    public void setUserFirstName(String UserFirstName) {
        this.UserFirstName = UserFirstName;
    }

    /**
     * @return the UserLastName
     */
    public String getUserLastName() {
        return UserLastName;
    }

    /**
     * @param UserLastName the UserLastName to set
     */
    public void setUserLastName(String UserLastName) {
        this.UserLastName = UserLastName;
    }

    /**
     * @return the UserPosition
     */
    public String getUserPosition() {
        return UserPosition;
    }

    /**
     * @param UserPosition the UserPosition to set
     */
    public void setUserPosition(String UserPosition) {
        this.UserPosition = UserPosition;
    }

    /**
     * @return the FacultyName
     */
    public String getFacultyName() {
        return FacultyName;
    }

    /**
     * @param FacultyName the FacultyName to set
     */
    public void setFacultyName(String FacultyName) {
        this.FacultyName = FacultyName;
    }

    /**
     * @return the DepartmentName
     */
    public String getDepartmentName() {
        return DepartmentName;
    }

    /**
     * @param DepartmentName the DepartmentName to set
     */
    public void setDepartmentName(String DepartmentName) {
        this.DepartmentName = DepartmentName;
    }

    /**
     * @return the UserTypeDesc
     */
    public String getUserTypeDesc() {
        return UserTypeDesc;
    }

    /**
     * @param UserTypeDesc the UserTypeDesc to set
     */
    public void setUserTypeDesc(String UserTypeDesc) {
        this.UserTypeDesc = UserTypeDesc;
    }

    /**
     * @return the UsertypeId
     */
    public int getUsertypeId() {
        return UsertypeId;
    }

    /**
     * @param UsertypeId the UsertypeId to set
     */
    public void setUsertypeId(int UsertypeId) {
        this.UsertypeId = UsertypeId;
    }

    /**
     * @return the kwKeyWord
     */
    public String getKwKeyWord() {
        return kwKeyWord;
    }

    /**
     * @param kwKeyWord the kwKeyWord to set
     */
    public void setKwKeyWord(String kwKeyWord) {
        this.kwKeyWord = kwKeyWord;
    }

    /**
     * @return the userEntity
     */
    public UserEntity getUserEntity() {
        return userEntity;
    }

    /**
     * @param userEntity the userEntity to set
     */
    public void setUserEntity(UserEntity userEntity) {
        this.userEntity = userEntity;
    }

    /**
     * @return the facultyList
     */
    public ArrayList<FacultyEntity> getFacultyList() {
        return facultyList;
    }

    /**
     * @param facultyList the facultyList to set
     */
    public void setFacultyList(ArrayList<FacultyEntity> facultyList) {
        this.facultyList = facultyList;
    }

    /**
     * @return the DepartmentList
     */
    public ArrayList<DepartmentEntity> getDepartmentList() {
        return DepartmentList;
    }

    /**
     * @param DepartmentList the DepartmentList to set
     */
    public void setDepartmentList(ArrayList<DepartmentEntity> DepartmentList) {
        this.DepartmentList = DepartmentList;
    }

    /**
     * @return the UserTypeList
     */
    public ArrayList<UserTypeEntity> getUserTypeList() {
        return UserTypeList;
    }

    /**
     * @param UserTypeList the UserTypeList to set
     */
    public void setUserTypeList(ArrayList<UserTypeEntity> UserTypeList) {
        this.UserTypeList = UserTypeList;
    }

    /**
     * @return the UserList
     */
    public ArrayList<UserEntity> getUserList() {
        return UserList;
    }

    /**
     * @param UserList the UserList to set
     */
    public void setUserList(ArrayList<UserEntity> UserList) {
        this.UserList = UserList;
    }

    /**
     * @return the userTypeEntity
     */
    public UserTypeEntity getUserTypeEntity() {
        return userTypeEntity;
    }

    /**
     * @param userTypeEntity the userTypeEntity to set
     */
    public void setUserTypeEntity(UserTypeEntity userTypeEntity) {
        this.userTypeEntity = userTypeEntity;
    }

//    /**
//     * @return the error
//     */
//    public String getError() {
//        return error;
//    }
//
//    /**
//     * @param error the error to set
//     */
//    public void setError() {
//        this.error = "<span style='color:red'>กรุณากรอกข้อมูลให้ครบถ้วน</span>";
//    }
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (null == UserId) {
            errors.add("userid", new ActionMessage("error.userid.missing"));
        }
        if (null == UserName) {
            errors.add("username", new ActionMessage("error.username.missing"));
        }

//    
//    if (getUserId() == null || getUserId().equalsIgnoreCase("")) {
//    errors.add("userid", new ActionMessage("error.userid.required"));
//    }
//    if (getUserName() == null || getUserName().equalsIgnoreCase("")) {
//    errors.add("username", new ActionMessage("error.username.required"));
//    }
//    if (getUserPassword() == null || getUserPassword().equalsIgnoreCase("")) {
//    errors.add("userpassword", new ActionMessage("error.userpassword.required"));
//    }
//    if (getUserTitle() == null || getUserTitle().equalsIgnoreCase("")) {
//    errors.add("usertitle", new ActionMessage("error.usertitle.required"));
//    }
//    if (getUserFirstName() == null || getUserFirstName().equalsIgnoreCase("")) {
//    errors.add("userfirstName", new ActionMessage("error.userfirstName.required"));
//    }
//    if (getUserLastName() == null || getUserLastName().equalsIgnoreCase("")) {
//    errors.add("userlastname", new ActionMessage("error.userlastname.required"));
//    }
//    if (getUserPassword() == null || getUserPassword().equalsIgnoreCase("")) {
//    errors.add("userposition", new ActionMessage("error.userposition.required"));
//    }
//    if (getFacultyName() == null || getFacultyName().equalsIgnoreCase("")) {
//    errors.add("facultyname", new ActionMessage("error.facultyname.required"));
//    }
//    if (getDepartmentName() == null || getDepartmentName().equalsIgnoreCase("")) {
//    errors.add("departmentname", new ActionMessage("error.departmentname.required"));
//    }
//    if (getUserTypeDesc() == null || getUserTypeDesc().equalsIgnoreCase("")) {
//    errors.add("usertypedesc", new ActionMessage("error.usertypedesc.required"));
//    }
        return errors;
    }
}
